from django.db import models

# Create your models here.
class User(models.Model):
    gender = (('Male', 'Male'),
               ('Female', 'Female'),
              )

    userId = models.AutoField(primary_key=True)
    user_name = models.CharField(max_length=100)
    first_name = models.CharField(max_length=100)
    last_name =  models.CharField(max_length=100)
    dob = models.DateField()
    email = models.EmailField(max_length=100)
    pwd = models.CharField(max_length=100)
    mobile = models.CharField(max_length=10)
    is_admin = models.BooleanField(default=True)
    gender = models.CharField(choices=gender, max_length=10)
    fbuid = models.CharField(max_length=100, blank=True, null=True)
    ttrid = models.CharField(max_length=100, blank=True, null=True)
    profile_image = models.ImageField(upload_to='profile_pics/', blank=True, null=True)
    is_active = models.BooleanField(default=True)
    # audit fields
    create_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    updated_by = models.CharField(max_length=100, default='self')

    def __unicode__(self):
        return '%s : %s' % (self.first_name, self.last_name)


class Follow(models.Model):
    followers = models.ForeignKey(User, related_name='follower')
    followings = models.ForeignKey(User, related_name='following')
    is_active = models.BooleanField(default=True)
    # audit fields
    create_at = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return '%s : %s' % (self.followers.first_name, self.followings.first_name)

